<template>
  <div id="app">
    <GoodsList @submit="submit" :data="records"></GoodsList>
  </div>
</template>

<script>
import GoodsList from './components/GoodsList.vue';



export default {
  components: {
    GoodsList
  },
  data () {
    return {
      records: [
        {
        id: 1,
        date: '2022-01-01',
        doctor: '张三',
        diagnosis: '感冒',
        prescription: '感冒药',
      },
        {
        id: 2,
        date: '2022-02-01',
        doctor: '李四',
        diagnosis: '头疼',
        prescription: '止疼药',
      },
        {
        id: 3,
        date: '2022-03-01',
        doctor: '王五',
        diagnosis: '腰痛',
        prescription: '止痛贴',
      }
      ]
    }
  },

  methods: {
    submit(e) { 
      if (e !== '') {
        this.records = this.records.filter(item => item.doctor === e)
      } else { 
        this.records = [
        {
        id: 1,
        date: '2022-01-01',
        doctor: '张三',
        diagnosis: '感冒',
        prescription: '感冒药',
      },
        {
        id: 2,
        date: '2022-02-01',
        doctor: '李四',
        diagnosis: '头疼',
        prescription: '止疼药',
      },
        {
        id: 3,
        date: '2022-03-01',
        doctor: '王五',
        diagnosis: '腰痛',
        prescription: '止痛贴',
      }
      ]
      }
    }
  }
}
</script>

<style>

</style>
